<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>gCalBirthdays Debug</title>	  
		<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
		
		<style type="text/css">
			/* Sets the iFrame scrollbars close to the browsers border */
			body {
				margin: 0px;
			}
		</style>
		
		<!--http://log4javascript.org-->
		<!--V1.4.1-->
		<script type="text/javascript" src="http://log4javascript.org/js/log4javascript_uncompressed.js"></script>
		
		<script type="text/javascript">
			var log = log4javascript.getLogger('main');
			var appender = new log4javascript.InPageAppender(null, false, false);
			appender.setMaxMessages(null);
			appender.setInitiallyMinimized(false);
			appender.setShowCommandLine(false);
			appender.setThreshold(log4javascript.Level.ALL);
			log.addAppender(appender);
			log.setLevel(log4javascript.Level.ALL);
			log.debug('gCalBirthdays Debug');
			log4javascript.setShowStackTraces(true);
		</script>
		
		<script>
			/* Events */
			
			/* Log4Javascript is using the body events - Append our custom functions */
			var loadLog = window.onload;
			window.onload = function() {
				loadLog();
				loadIFrame();
			}
			window.onresize = function() {
				resizeIFrame();
			}
			window.onerror = function(msg, url, linenumber){
				handleError(msg, url, linenumber);
			}
			
			/* Event functions */
			
			/* Load Page */
			function loadIFrame() {
				createIFrame();
				hideLog4JavascriptElements();
			}
			
			/* Resize iFrame */
			function resizeIFrame() {
				try {
					/* Resize gCalBirthdays iFrame: BrowserWindow -  LoggerWindow - LoggerBorder */
					var ifr = document.getElementById('gCBDIFrame');
					ifr.style.height = window.innerHeight - parseInt(appender.getHeight()) - 1;
				}
				catch(err) {
					setTimeout(resizeIFrame, 100);
				}
			}
			
			/* Log unhandled javascript errors */
			function handleError(msg, url, linenumber) {
				log.error(msg+'\n\t URL: '+url+'\n\t Line Number: '+linenumber);
				try {
					console.error(msg+'\n\t URL: '+url+'\n\t Line Number: '+linenumber);
				} catch(err) {}
			}
			
			/* Subfunctions */
			
			/* Create iFrame */
			function createIFrame() {
				var iframe = document.createElement('iframe');
				iframe.id = 'gCBDIFrame';
				iframe.src = 'gCalBirthdays.html';
				iframe.width = '100%';
				iframe.frameBorder = 'no';
				iframe.scrolling = 'auto';
				iframe.onload = function () {
					injectScript(this.contentDocument);
					injectHTML(this.contentDocument);
				};
				document.body.appendChild(iframe);
				/* Adjust size */
				resizeIFrame();
			}
			
			/* Inject script */
			function injectScript(o) {
				var el = document.createElement('script');
				/* If Firebug is active, overwriting console results in error: */
				/* Error: setting a property that has only a getter */
				el.innerHTML = 'try { \
													console = parent.log; \
													function printLog(text) { parent.log.trace(text); } \
													window.onerror = parent.handleError; \
												} catch(err) { \
													function printDebug(text) { parent.log.debug(text); } \
													function printLog(text) { parent.log.trace(text); } \
													window.onerror = parent.handleError; \
												};';
				o.body.appendChild(el);
			}
			
			/* Inject HTML */
			function injectHTML(o) {
				var el = document.createElement('H1');
				el.innerHTML=' gCalBirthdays DEBUG';
				o.body.insertBefore(el, o.body.firstChild); 
				var el2 = el.cloneNode(true);
				o.body.appendChild(el2);
			}
			
			/* Hide Log4Javascript Elements */
			function hideLog4JavascriptElements() {
				try {
					/* Hide Log4Javascript Toolbar Level Search Options */
					var el = document.createElement('style');
					el.type = 'text/css';
					el.innerHTML = '#switches { visibility:hidden; height: 0px } ';
					appender.getConsoleWindow().document.body.appendChild(el);
				}
				catch(err) {
					setTimeout(hideLog4JavascriptElements, 100);
				}
			}
		</script>
		
		<!--Google Analytics-->
		<script type="text/javascript">
			var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
			document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
		</script>
		<script type="text/javascript">
			try {
				var pageTracker = _gat._getTracker("UA-9798979-1");
				pageTracker._trackPageview();
			}
			catch(err) {}
		</script>
	</head>
	
	<body>
	</body>
	
</html>
